﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Entities;
using Utility;
using BUS;

public partial class Administrator_khachhang_sua : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            load_data();
        }
    }
    private void load_data()
    {
        int id = int.Parse(Request.QueryString["id"].ToString());
        Tbl_KhachHang_Entities kh = Tbl_KhachHang_BUS.GetByID(id);
        Literal1.Text = id.ToString();
        txt_tendn.Text = kh.TaiKhoan;
        txt_mk.Text = kh.MatKhau;
        txt_hoten.Text = kh.HoTen;
        txt_dc.Text = kh.DiaChi;
        txt_sdt.Text = kh.SDT;
        txt_email.Text = kh.Email;
        txt_sodu.Text = kh.Sodutaikhoan.ToString();

    }

    protected void bt_ok_Click(object sender, EventArgs e)
    {
        Tbl_KhachHang_Entities kh = Tbl_KhachHang_BUS.GetByID(int.Parse(Literal1.Text));
        kh.STT = int.Parse(Literal1.Text);
        kh.TaiKhoan = txt_tendn.Text;
        kh.MatKhau = txt_mk.Text;
        kh.HoTen = txt_hoten.Text;
        kh.DiaChi = txt_dc.Text;
        kh.SDT = txt_sdt.Text;
        kh.Email = txt_email.Text;
        kh.Sodutaikhoan = float.Parse(txt_sodu.Text);

        Tbl_KhachHang_BUS.Update(kh);
        Literal1.Text = "Cập nhật thành công";
        HyperLink1.Visible = true;
        HyperLink1.Text = "Về trang danh sách Hình Thức Thanh Toán";
        HyperLink1.NavigateUrl = "~/Administrator/khachhang_ds.aspx";


    }
}
